package com.example.jetpacklearn.liftcycle

import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LifecycleOwner

/**
 *
 * @ClassName:      ActivityLifeObserver$
 * @Description:    java类作用描述
 * @Author:         xinya
 * @CreateDate:     2020/11/2$ 12:19$
 * @UpdateRemark:   更新内容
 * @Version:        1.0
 */
class ActivityLifeObserver : LifecycleEventObserver {
    companion object {
        private const val TAG = "ActivityLifeObserver"
    }

    override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
        when (event) {
            Lifecycle.Event.ON_CREATE -> {
                Log.d(TAG, "onStateChanged: ON_CREATE")
            }
            Lifecycle.Event.ON_START -> {
                Log.d(TAG, "onStateChanged: ON_START")
            }
            Lifecycle.Event.ON_RESUME -> {
                Log.d(TAG, "onStateChanged: ON_RESUME")
            }
            Lifecycle.Event.ON_PAUSE -> {
                Log.d(TAG, "onStateChanged: ON_PAUSE")
            }
            Lifecycle.Event.ON_STOP -> {
                Log.d(TAG, "onStateChanged: ON_STOP")
            }
            Lifecycle.Event.ON_DESTROY -> {
                Log.d(TAG, "onStateChanged: ON_DESTROY")
            }
            else -> {
                Log.d(TAG, "onStateChanged: else")
            }
        }
    }
}